module.exports = function ($scope, $resource, toaster) {

    $scope.bean = {};
    $resource('/api/as/mc/shop/findShopProduct', {}, {}).save({}, function (res) {
        if (res.errcode === 0) {
            $scope.bean = res.data;
        } else {
            toaster.error({ title: '', body: res.errmsg });
        }
    });

    //保存
    $scope.ok = function () {
        if ($scope.bean.profit_level1 + $scope.bean.profit_level2 + $scope.bean.profit_level3 == 100) {
            $resource('/api/as/mc/shop/updateShopProduct', {}, {}).save($scope.bean, function (res) {
                if (res.errcode === 0) {
                    toaster.success({ title: '', body: '操作成功' });
                    $modalInstance.close();
                } else {
                    toaster.error({ title: '', body: res.errmsg });
                }
            });
        } else {
            alert('三级分润总和应为百分百');
        }
        
    }

};